﻿var finished=true;
function changeShowPic(a){
	$("#example img").attr("src",a);
}
function inputWordFocus(){
	var tele = document.getElementById("word");
	if (tele.innerHTML == "请输入自定义文字") {
		tele.innerHTML = "";
	}
	tele.style.color = "#000000";
}
function showUpload1(){
	$("#uploaddiypicture").dialog("open");
}
function redesign(){
	$.getJSON("getReDesignMessage.action",{
		id:$("#hiddenid").val(),
		type:$("#hiddentype").val()
	},function(data){
		$("#example").fadeOut(1000);
		$("#selectMore").fadeOut(1000);
		$("#imgleft").fadeOut(1000);
		$("#imgright").fadeOut(1000);
		setTimeout(function(){
			$("#tooltip").fadeIn(1000);
			$("#leftSelectDiv").fadeIn(1000);
			$("#hiddenpicdetaillistsize").attr("value",data.picdetaillistsize);
			var bg=document.getElementById("bg");
			bg.setAttribute("style", "height:480px;width:640px;left:191px;border:1px solid #A8D9E9;background:url('"+data.bgPic+"') no-repeat scroll center bottom transparent;");
			var tt=0;
			$.each(data.picdetaillist,function(index,value){
				var divv=document.createElement("div");
				divv.setAttribute("id", "divv"+tt);
				divv.setAttribute("style", "position:absolute;left:"+value.left+";top:"+value.top+";width:"+value.width+";height:"+value.height+"");
				bg.appendChild(divv);
				$("#divv" + tt).draggable({
					containment : '#bg'
				});
				var chacha=document.createElement("div");
				chacha.setAttribute("style", "height:10px;display:block");
				chacha.setAttribute("id", "chacha"+tt);
				divv.appendChild(chacha);
				var img=document.createElement("img");
				img.setAttribute("id", "imgc"+tt);
				img.setAttribute("src", "img/cancel_03.png");
				img.setAttribute("value", tt);
				img.setAttribute("style", "z-index:1000;display: block; position: relative; left: -10px; float: left; width: 12px; height: 10px;");
				img.setAttribute("onclick", "var cancelnum = $(this).attr('value');document.getElementById('flag'+ cancelnum).value = 0;document.getElementById('divv'+ cancelnum).style.display = 'none';");
				chacha.appendChild(img);
				var flag=document.createElement("input");
				flag.setAttribute("type", "hidden");
				flag.setAttribute("value", "1");
				flag.setAttribute("id", "flag"+tt);
				flag.setAttribute("name", "flagname");
				divv.appendChild(flag);
				var img1=document.createElement("img");
				img1.setAttribute("id", "imgg"+tt);
				img1.setAttribute("src", value.picUrl);
				img1.setAttribute("style", "width:"+value.width+"px;height:"+value.height+"px;");
				divv.appendChild(img1);
				$("#imgg" + tt).resizable();
				tt=tt+1;
			});
		},1000);
	});
	$(".shareinfo_content_left_productionshare_dingzhi").fadeOut("slow");
	$(".share_content_right").fadeOut("slow");
	$("#contentBody").css("width","650px");

	addDrop();
}


function hideTypeSelect(){
	$("#leftlist").slideUp("slow");
	$("#openchexing").show();
}
function hideGongjukuang(){
	$("#tooltip").slideDown("slow");
}

function sendCommentAtDetail(a,b){
	if ($("#showusersNamea1").html() == ""|| $("#showusersNamea1").html() == 'null') {
		$("#login").dialog("open");
	} else {
		var comm = $("#inputcontent").val();
		if (comm == '') {
			//alert("请输入内容");
			$.weeboxs.open('请输入内容!', {
				title:'提示',
				timeout:5,
				showCancel:false,
				okBtnName: '确定',
			});
		} else {
			//$.getJSON("insertIntoComment.action",{id : a,type : b,comment : comm});
			document.getElementById("plform").submit();
			//alert("评论成功");
			$.weeboxs.open('评论成功!', {
				title:'提示',
				timeout:5,
				showCancel:false,
				okBtnName: '确定',
			});
			setTimeout(function(){
				refreshComm(a,b);
			},100);
			$("#inputcontent").val("");
			$("#plform input[type='file']").val("");
		}
	}
}

function refreshComm(id,type){
	$.getJSON("refreshCommAtShareDetail.action",{id:id,type:type,dd:new Date().getTime()},function(data) {// 返回新的评论信息，和评论条数
		$("#itemContainerr").html("");
		var usertext = document.getElementById("itemContainerr");
		$.each(data.clist,function(i, v) {
			var out = document.createElement("div");
			out.setAttribute("class","shareinfo_content_left_usercomment_child animated flash");
			out.setAttribute("style", "display:block;");
			usertext.appendChild(out);
			var in1 = document.createElement("div");
			var in2 = document.createElement("div");
			in2.setAttribute("style","clear:both;margin-top:12px;text-align:left");
			out.appendChild(in1);
			out.appendChild(in2);
			var name = document.createElement("div");
			name.setAttribute("style","float: left;");
			var comme = document.createElement("div");
			comme.setAttribute("style","float:left;margin-left:10px;text-align:left;");
			in1.appendChild(name);
			in1.appendChild(comme);
			var shiliao = document.createElement("font");
			shiliao.setAttribute("style","margin-left:50px;");
			shiliao.innerHTML = v.commentTime_bak;
			var jubao = document.createElement("a");
			jubao.setAttribute("style","float:right;");
			jubao.setAttribute("href","javascript:reportSomebody("+v.commentId+")");
			jubao.innerHTML = "举报";
			in2.appendChild(shiliao);
			in2.appendChild(jubao);
			name.innerHTML = "<img width='50px' height='50px' onclick='getUserMessage(\""+v.userName+"\");' src='"+v.userFace+"'>";
			//comme.innerHTML = "<font color='#666'>"+v.userName+"</font><br/>"+v.commentContent+"";
			var f1=document.createElement("font");
			f1.setAttribute("color", "#666");
			f1.innerHTML=v.userName;
			var b1=document.createElement("br");
			comme.appendChild(f1);comme.appendChild(b1);
			if(v.commPic!=''&&v.commPic!=null){
				var i1=document.createElement("img");
				i1.setAttribute("src", v.commPic);
				i1.setAttribute("title", "点击查看原图,右键下载图片");
				i1.setAttribute("style", "height:130px;width:auto;");
				i1.setAttribute("onclick", "$(this).parent().fancybox({'padding':0,'margin':0});");
				//comme.appendChild(i1);
				var aa=document.createElement("a");
				aa.setAttribute("href", v.commPic);
				aa.appendChild(i1);
				comme.appendChild(aa);
			}
			comme.innerHTML+=v.commentContent+"&nbsp;";
			if(v.filePath!=''&&v.filePath!=null){
				var a1=document.createElement("img");
				a1.setAttribute("style","width:22px;height:22px;cursor:pointer;");
				a1.setAttribute("src","images/xiazai.png");
				a1.setAttribute("title", "下载设计图片");
				a1.setAttribute("onclick","window.location.href=window.location.href='downloadFile1?path="+v.filePath+"&&filename="+v.fileName+"'");
				comme.appendChild(a1);
			}
		});
		//document.getElementById("listsizeNomalspan").innerHTML(data.listsize);
		jPagesresign('itemContainerr','#bottom111');
	});
}

function changeToDetail(a,b){
	window.location.href="showParticipateDetail.action?id="+a+"&&type="+b+"";
}

function clickShareOut(a,b){
	if($("#hiddenflagshare").val()==0){
		if ($("#showusersNamea1").html() == ""|| $("#showusersNamea1").html() == 'null') {
			$("#login").dialog("open");
			$("#hiddenflagshare").val("1");
		} else {
			$.ajax({url:"gotoParticipateOut.action",data:{id:a,type:b}});
		}
	}else{
		if ($("#showusersNamea1").html() != ""&&$("#showusersNamea1").html() != 'null') {
			$.ajax({url:"gotoParticipateOut.action",data:{id:a,type:b}});
		}
	}
}


